package com.cyf.plc.viewholder

import androidx.recyclerview.widget.RecyclerView
import com.cyf.plc.BR
import com.cyf.plc.adapter.RoomAdapter
import com.cyf.plc.databinding.ItemRoomBinding
import com.cyf.plc.model.PlcRoom

class RoomViewHolder(private val binding: ItemRoomBinding) : RecyclerView.ViewHolder(binding.root) {

    fun bind(room: PlcRoom, onItemClickListener: RoomAdapter.OnItemClickListener? = null) {
        binding.setVariable(BR.room, room)

        onItemClickListener?.let { listener ->
            binding.root.setOnClickListener {
                listener.onItemClicked(room, binding.root)
            }
            binding.root.setOnLongClickListener {
                listener.onItemLongClick(room, binding.root)
                false
            }
        }

    }
}